package io.gitee.thinkbungee.exception;

import io.gitee.thinkbungee.constant.SatelliteConstant;
import lombok.Data;

/**
 * @author chenyichang
 * @date 2022/2/21
 */
@Data
public class BusinessException extends RuntimeException {
    /**
     * 异常码
     */
    private String code;
    /**
     * 异常参数
     * 数组类型
     */
    private Object[] args;

    public BusinessException(String code) {
        this.code = code;
    }

    public BusinessException(String code, Object... args) {
        this.code = code;
        this.args = args;
    }


    public static BusinessException build(SatelliteConstant.Exception exception) {
        return new BusinessException(exception.getCode(), exception.getArg());
    }

    public static BusinessException build(String code, Object... args) {
        return new BusinessException(code, args);
    }

}
